package com.itheima.mp.time;

public class CustomRounding {
    public static void main(String[] args) {
        int number = 4449;
        int roundedNumber = roundUp(number);
        System.out.println("Original number: " + number);
        System.out.println("Rounded number: " + roundedNumber);
    }

    public static int roundUp(int number) {
        if (number < 0) {
            return -roundUp(-number); // 处理负数
        }
        int length = (number == 0) ? 1 : (int) Math.log10(number) + 1; // 计算数字的位数
        int powerOfTen = (int) Math.pow(10, length - 1); // 计算10的幂次
        return ((number / powerOfTen) + 1) * powerOfTen; // 四舍五入到下一个10的幂次
    }
}